import { createRouter, createWebHistory } from 'vue-router'
let routes = [
  {
    path: '/',
    name: '/',
    meta: { title: '首页' },
    component: () => import('../view/login.vue')
  },
  {
    path: '/test',
    name: '/test',
    meta: { title: '首页' },
    component: () => import('../view/test.vue')
  },
  {
    path: '/login',
    name: '/login',
    meta: { title: '登录' },
    component: () => import('../view/login.vue')
  }
];

const router = createRouter({
  history: createWebHistory(),//'hash'
  routes
});
// router.beforeEach((to, from, next) => {
//   // 如果访问的是登录界面则直接放行
//   if (to.path === '/login') return next()
//   //获取用户页面token信息
//   let token = window.sessionStorage.getItem('token')
//   //如果token数据为null则跳转到指定路径
//   if (!token) return next('/login')
//   next()
// })
export default router;
